package com.gin.kotlin.no_gay_alliance.adapter.reply

import android.content.Context
import com.gin.kotlin.no_gay_alliance.R
import com.gin.kotlin.no_gay_alliance.base.AbstractBindingRecyclerViewAdapter
import com.gin.kotlin.no_gay_alliance.base.MyHandler
import com.gin.kotlin.no_gay_alliance.databinding.ItemTextBinding
import com.gin.nga.enums.Evaluation
import com.gin.nga.response.alter.ReputationLog

/**
 * 操作记录适配器
 */
class ReputationLogAdapter(context: Context, handler: MyHandler) : AbstractBindingRecyclerViewAdapter<ItemTextBinding, ReputationLog>(context, handler, false) {
    /**
     * 当显示某一位置的item时的操作
     * @param holder ViewHolder
     * @param position Int
     * @param b ViewBinding
     * @param dataModel 数据对象
     */
    override fun onBindViewHolder(holder: ViewHolder<ItemTextBinding>, position: Int, b: ItemTextBinding, dataModel: ReputationLog) {
        // 字体颜色
        b.root.setTextColor(
            when (dataModel.evaluation) {
                Evaluation.POSITIVE -> getAttrColor(R.attr.textColorBlue)
                Evaluation.NEGATIVE -> getAttrColor(R.attr.textColorRed)
                Evaluation.NEUTRAL -> getAttrColor(R.attr.textColor)
            }
        )

        // 文字内容
        b.root.text = dataModel.getDescription()

    }
}